import { makeObservable,observable,action } from "mobx";
import {getRank,getRankAns} from '../../api/goodRank'

interface IRank {
    rankId: number;
    rankName: string;
    rankDesc: string
}
class RankStore {
    constructor(){
        makeObservable(this)
    }
    @observable rankInfo:Array<any | IRank> = [{}]
    @action.bound setRank(data: Array<any>){
        this.rankInfo = data
    }
    @action.bound getGoodsRank(){
        getRank()
            .then(res => {
                const {data,code} = res as unknown as getRankAns
                if(code === 200){
                    this.setRank(data)
                }
            })
            .catch(err => {
                console.log(err);
            })
    }
}

export default RankStore